package com.crime.crimemonitorclient;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.crimemonitor.library.CrimeSummary;
import com.crimemonitor.library.CrimeTimeSeriesObservation;

public class CrimeTimeSeriesListAdapter extends ArrayAdapter<CrimeTimeSeriesObservation> {

	private final Context mContext;
	
	public CrimeTimeSeriesListAdapter(Context context)
	{
		super(context, R.layout.crime_timeseries_rowlayout, R.id.crime_timeseries_view);
		
		this.mContext = context;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = (LayoutInflater)this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		
		View rowView = inflater.inflate(R.layout.crime_timeseries_rowlayout, parent, false);
		TextView observationRowView = (TextView)rowView.findViewById(R.id.crime_timeseries_view);
		observationRowView.setText(this.getItem(position).toString());
		
		return rowView;
	}
}
